package com.winsomely.leecode;

/**
 * 最大连续1的个数
 * 
 * @author liujiawei
 * 1,3,6,3,2,4,6,8,5,34,2,5,7,
 *
 */
public class FindMaxConsecutiveOnes {

	public int findMaxConsecutiveOnes(int[] nums) {
		int max = 0;
		int cur = 0;
		for (int i = 0; i < nums.length; i++) {
			int s = nums[i];
			if (s == 0) {
				max = Math.max(max, cur);
				cur = 0;
			} else {
				cur++;
			}
		}
		return Math.max(max, cur);
	}

	public static void main(String[] args) {
		FindMaxConsecutiveOnes t = new FindMaxConsecutiveOnes();
		int[] nums = { 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1 ,0};
		System.out.println(t.findMaxConsecutiveOnes(nums));
	}

}
